home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-02-09 | 3.5 KB | 116 lines | [TEXT/R*ch] |
- /*
- File: CPowerPanel.cp
-
- Contains: Class stub to use as a template for creating your own multi-pane
- dialog panels.
-
- Written by: Mike Shields
-
- Copyright: Copyright © 1996 Mike Shields. All Rights Reserved.
-
- Change History (most recent first):
-
- 02/01/96 MSS New
- To Do:
- */
- #include "CPowerPanel.h"
-
- #include <LStream.h>
- #include <LControl.h>
-
- struct SPowerPanelRec
- {
- Int16 enegyMode;
- Int16 warpDrive;
- Int16 thermRadiators;
- Int16 emergencyPower;
- };
-
- typedef struct SPowerPanelRec PowerPanelRec, *PowerPanelDataPtr, **PowerPanelDataHandle;
-
- //---------------------------------------------------------------------------
- // CPowerPanel::CreateFromStream
- //---------------------------------------------------------------------------
- CPowerPanel* CPowerPanel::CreateFromStream(LStream* inStream)
- {
- return (new CPowerPanel(inStream));
- }
-
- //---------------------------------------------------------------------------
- // CPowerPanel::CPowerPanel
- //---------------------------------------------------------------------------
- CPowerPanel::CPowerPanel()
- {
- }
-
- //---------------------------------------------------------------------------
- // CPowerPanel::CPowerPanel
- //---------------------------------------------------------------------------
- CPowerPanel::CPowerPanel(const CPowerPanel &inOriginal)
- : CMPDPanel(inOriginal)
- {
- }
-
- //---------------------------------------------------------------------------
- // CPowerPanel::CPowerPanel
- //---------------------------------------------------------------------------
- CPowerPanel::CPowerPanel(const SPaneInfo &inPaneInfo, const SViewInfo &inViewInfo)
- : CMPDPanel(inPaneInfo, inViewInfo)
- {
- }
-
- //---------------------------------------------------------------------------
- // CPowerPanel::CPowerPanel
- //---------------------------------------------------------------------------
- CPowerPanel::CPowerPanel(LStream *inStream)
- : CMPDPanel(inStream)
- {
- }
-
- //---------------------------------------------------------------------------
- // CPowerPanel::CPowerPanel
- //---------------------------------------------------------------------------
- CPowerPanel::~CPowerPanel()
- {
- }
-
- //---------------------------------------------------------------------------
- // CPowerPanel::GetData
- //---------------------------------------------------------------------------
- void CPowerPanel::GetData(Handle inDataToReplace)
- {
- LControl *aControl;
- PowerPanelRec newPrefs;
-
- aControl = (LControl*)this->FindPaneByID('Save');
- newPrefs.enegyMode = aControl->GetValue();
- aControl = (LControl*)this->FindPaneByID('Warp');
- newPrefs.warpDrive = aControl->GetValue();
- aControl = (LControl*)this->FindPaneByID('Ther');
- newPrefs.thermRadiators = aControl->GetValue();
- aControl = (LControl*)this->FindPaneByID('Emer');
- newPrefs.emergencyPower = aControl->GetValue();
-
- OSErr anErr = ::PtrToXHand(&newPrefs, inDataToReplace, sizeof(newPrefs));
- ThrowIfOSErr_(anErr);
- }
-
- //---------------------------------------------------------------------------
- // CPowerPanel::SetData
- //---------------------------------------------------------------------------
- void CPowerPanel::SetData(Handle inData)
- {
- LControl *aControl;
- PowerPanelDataHandle newPrefs = (PowerPanelDataHandle)inData;
-
- aControl = (LControl*)this->FindPaneByID('Save');
- aControl->SetValue((**newPrefs).enegyMode);
- aControl = (LControl*)this->FindPaneByID('Warp');
- aControl->SetValue((**newPrefs).warpDrive);
- aControl = (LControl*)this->FindPaneByID('Ther');
- aControl->SetValue((**newPrefs).thermRadiators);
- aControl = (LControl*)this->FindPaneByID('Emer');
- aControl->SetValue((**newPrefs).emergencyPower);
- }
-
-